<?php

namespace App\Repository\Main;

use App\Repository\BaseRepository;
use App\Repository\Main\OrderPdd;
use App\Repository\UpThree\GetThreeOrderRepostition;
use Monolog\Logger;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\RotatingFileHandler;


class PddRepository extends  BaseRepository
{
  private $log;
  public function __construct()
  {
    $this->log = new Logger('PddOrder');
    $this->log->pushHandler(
      (new RotatingFileHandler(storage_path('/logs/PddOrder.log'), 14, Logger::DEBUG, true, 0777))->setFormatter(new LineFormatter(null, null, true, true))
    );
    parent::__construct();
  }
  //异步信息 全部都需要走这个地方 
  public function sendOrder($data = array(), $type = '')
  {
    // 都需要对应成功或失败
    $res = [];
    switch ($type) {
      case 'pddCreatOrder':
        // 抓取订单
        // 订单提交
        break;
      case 'pddSubmitOrder':
        break;
      case '':
        break;
    }
    $this->log->info('类型:' . $type . '参数:' . json_encode($data) . '返回的结果:' . json_encode($res));
    if (empty($res['code']) || $res['code'] != 200) {
      // 这个地方可以重新提交
    }
    return $res;
  }
}
